package com.dailyblue.example.springcloud.provider.controller;

import com.dailyblue.example.springcloud.commons.util.JsonResult;
import com.dailyblue.example.springcloud.commons.util.ResultTool;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/provider")
public class ProviderController {

    @Value("${server.port}")
    private Integer port;

    @GetMapping("/a")
    public JsonResult a() {
        log.info("port:{}", port);
        return ResultTool.success("This is ProviderController`a method!port:" + port);
    }

    @GetMapping("/b")
    public JsonResult b(int a) {
        log.info("param:{},port:{}", a, port);
        return ResultTool.success("This is ProviderController`b method!port:" + port + ",param:" + a);
    }

    @GetMapping("/c/{a}")
    public JsonResult c(@PathVariable int a) {
        log.info("param:{},port:{}", a, port);
        return ResultTool.success("This is ProviderController`c method!port:" + port + ",param:" + a);
    }

    @GetMapping("/d")
    public JsonResult d(int age) {
        log.info("age:{}", age);
        return ResultTool.success("This is ProviderController`d method!age:" + age);
    }
}
